package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;

public final class consult_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.Vector _jspx_dependants;

  private org.apache.jasper.runtime.ResourceInjector _jspx_resourceInjector;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html");
      response.setHeader("X-Powered-By", "JSP/2.1");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector = (org.apache.jasper.runtime.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("<html>\n");
      out.write("<head><title>User interface with JSP</title></head>\n");
      out.write("<body>\n");
      out.write("<h1>Looking for someone ?</h1><br>\n");
      out.write("<form method =\"get\">\n");
      out.write("<p>\n");
      out.write("Name:&nbsp;<input type=\"text\" name=\"prefix\"/>\n");
      out.write("<br/><input type=\"submit\" name=\"searchPerson\" value =\"Search !\"/>\n");
      out.write("<br/><input type=\"submit\" name=\"searchallPerson\" value =\"Search All !\"/>\n");
      out.write("</p>\n");
      out.write("</form>\n");
      out.write("<h1>Looking for a card ?</h1><br>\n");
      out.write("<form method =\"get\">\n");
      out.write("<p>\n");
      out.write("Name:&nbsp;<input type=\"text\" name=\"prefix\"/>\n");
      out.write("<br/><input type=\"submit\" name=\"searchCard\" value =\"Search !\"/>\n");
      out.write("<br/><input type=\"submit\" name=\"searchallCard\" value =\"Search All !\"/>\n");
      out.write("</p>\n");
      out.write("</form>\n");

boolean all = request.getParameter("searchallPerson")!=null;
if(all)
	out.println("prefix ="+request.getParameter("prefix"));		

      out.write('\n');
      tpcar.ejb.ConsultPersonneBean ConsultPersonneBean = null;
      synchronized (request) {
        ConsultPersonneBean = (tpcar.ejb.ConsultPersonneBean) _jspx_page_context.getAttribute("ConsultPersonneBean", PageContext.REQUEST_SCOPE);
        if (ConsultPersonneBean == null){
          ConsultPersonneBean = new tpcar.ejb.ConsultPersonneBean();
          _jspx_page_context.setAttribute("ConsultPersonneBean", ConsultPersonneBean, PageContext.REQUEST_SCOPE);
          out.write('\n');
          out.write('\n');
        }
      }
      out.write('\n');

List<Personne> personnes =  ConsultPersonneBean.listerTous();
if (personnes == null|| personnes.isEmpty()) {
	out. println ("<strong> No match found ! </strong>");
}else {
	for (Personne personne : personnes) {
		out.println("<h4>" + personne.getNom () + " " + personne.getPrenom() + "</h4>");
		out.println("<ul>");
		out.println("<li>Place of Birth: "+ personne.getLieuNaissance() +"</li>");
		out.println("<li>Date of Birth: "+ personne.getDateNaissance() +"</li>");
		out.println("<li>Gender: "+ personne.getSexe() +"</li>");
		out.println("</ul>");
	}
}

      out.write("\n");
      out.write("\n");
      out.write("</body>\n");
      out.write("</html>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
